package net.sansi.v3correctserver.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sansi.v3correctserver.dto.R;
import net.sansi.v3correctserver.dto.areamerge.AreaMergeDto;
import net.sansi.v3correctserver.service.correct.AreaMergeService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by Fang
 * create time : 2024/11/5
 * IDE : IntelliJ IDEA
 * <p>
 * 融合拼接接口
 */

@Api(tags = "区域融合")
@RestController
@RequestMapping("/merge")
@Validated
public class AreaMergeController {

    @Resource
    private AreaMergeService areaMergeService;

    /**
     * 矩形屏所有区域融合
     *
     * @return 融合成功或失败
     */
    @ApiOperation("矩形屏所有区域融合")
    @PostMapping("/rect/all")
    public R<String> rectAll(@RequestBody @Validated AreaMergeDto.RectAllReq form) {
        return R.status(areaMergeService.mergeAll(form.getTarget()));
    }

    /**
     * 矩形屏部分区域融合
     *
     * @return 融合成功或失败
     */
    @ApiOperation("矩形屏部分区域融合")
    @PostMapping("/rect/by-ids")
    public R<String> rectIds(@RequestBody @Validated AreaMergeDto.RectIdsReq form) {
        return R.status(areaMergeService.mergeAll(form.getTarget()));
    }
}
